﻿using System;
using WebApi.Hal;

namespace HAL_WebAPI_Demo.Controllers.Resources
{
    public class AccountRepresentation : Representation
    {
        public int Id { get; set; }
        public string Account { get; set; }
        public string Password { get; set; }
        public DateTime CreateDate { get; set; }
        public bool IsValid { get; set; }

        public int? EmployeeId { get; set; }

        public override string Rel
        {
            get
            {
                return LinkTemplates.Accounts.Account.Rel;
            }

            set { }
        }

        public override string Href
        {
            get
            {
                return LinkTemplates.Accounts.Account.CreateLink(new { id = Id }).Href;
            }

            set
            {
            }
        }

        protected override void CreateHypermedia()
        {
            if (EmployeeId != null)
                Links.Add(LinkTemplates.Employees.Employee.CreateLink(new { id = EmployeeId }));
        }
    }
}